package com.ai.databao.common.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class ServiceUtil implements ApplicationContextAware{

	private static ApplicationContext applicationContext; 

	@Override
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		ServiceUtil.applicationContext = applicationContext;  
	}

	public static Object getBean(String name) throws BeansException {  
	    return applicationContext.getBean(name);  
	}
	
	public static <T> T getBean(Class<T> requiredType){
		return applicationContext.getBean(requiredType);
	}
}